package br.com.LeitorLog.gui;

import java.awt.EventQueue;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;

import br.com.LeitorLog.gui.util.ConstantesGUI;

/**
 * Principal
 *
 * @since 29/01/2013 16:10:18
 */
public class Principal {

	private JFrame aframe;
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		
		setarAparencia();
		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Principal window = new Principal();
					window.aframe.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Principal() {
		initialize();
	}
	
	/**
	 * Seta a aparencia da aplicação.
	 */
	private static void setarAparencia() {
		try { 
	        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");	        
	    } catch(Exception e){
	    	// Exception
	    }
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		aframe = new JFrame();
		aframe.setTitle(ConstantesGUI.Mensagens.APP_TITLE);
		aframe.setBounds(100, 100, 900, 500);
		aframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		aframe.setIconImage(ConstantesGUI.Icones.SWORD_SHIELD);
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
		tabbedPane.setBorder(null);
		
		GroupLayout groupLayout = new GroupLayout(aframe.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 700, Short.MAX_VALUE)
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 340, Short.MAX_VALUE)
					.addContainerGap())
		);
		
		// adicionando as tabs
		tabbedPane.addTab(ConstantesGUI.Mensagens.MSG_LOG_ITENS, ConstantesGUI.Icones.SWORD, new PainelItem());
		tabbedPane.addTab(ConstantesGUI.Mensagens.MSG_LOG_ERRO, ConstantesGUI.Icones.ERRO, new PainelTabela());
		tabbedPane.addTab(ConstantesGUI.Mensagens.MSG_SOBRE, ConstantesGUI.Icones.SOBRE,new PainelSobre());
		
		// ABA DE LOG ERRO AINDA NÃO IMPLEMENTADA
//		tabbedPane.setEnabledAt(1, false);
//		tabbedPane.setToolTipTextAt(1, "Em desenvolvimento!");
		
		aframe.getContentPane().setLayout(groupLayout);
		//aframe.setResizable(false);
	}
}
